<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取最后发生的错误</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.error-clear-last.html">« error_clear_last</a></li>
      <li style="float: right;"><a href="function.error-log.html">error_log »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.errorfunc.html">错误处理 函数</a></li>
    <li>获取最后发生的错误</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.error-get-last" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">error_get_last</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">error_get_last</span> &mdash; <span class="dc-title">获取最后发生的错误</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.error-get-last-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>error_get_last</strong></span>(): <span class="type"><span class="type">?</span><span class="type">array</span></span></div>

  <p class="para rdfs-comment">
   获取关于最后一个发生的错误的信息。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.error-get-last-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.error-get-last-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回了一个关联数组，描述了最后错误的信息，以该错误的 &quot;type&quot;、
   &quot;message&quot;、&quot;file&quot; 和 &quot;line&quot; 为数组的键。
   如果该错误由 PHP 内置函数导致的，&quot;message&quot;会以该函数名开头。
   如果还没有错误则返回 <strong><code>null</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.error-get-last-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-516">
    <p><strong>示例 #1 An <span class="function"><strong>error_get_last()</strong></span> 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">error_get_last</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [type] =&gt; 8
    [message] =&gt; Undefined variable: a
    [file] =&gt; C:\WWW\index.php
    [line] =&gt; 2
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.error-get-last-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="errorfunc.constants.html" class="link">Error 常量</a></li>
    <li class="member"><var class="varname"><a href="reserved.variables.phperrormsg.html" class="classname">$php_errormsg</a></var> 变量</li>
    <li class="member"><span class="function"><a href="function.error-clear-last.html" class="function" rel="rdfs-seeAlso">error_clear_last()</a> - 清除最近一次错误</span></li>
    <li class="member"><a href="errorfunc.configuration.html#ini.display-errors" class="link"><code class="parameter">display_errors</code> 指令</a></li>
    <li class="member"><a href="errorfunc.configuration.html#ini.html-errors" class="link"><code class="parameter">html_errors</code> 指令</a></li>
    <li class="member"><a href="errorfunc.configuration.html#ini.xmlrpc-errors" class="link"><code class="parameter">xmlrpc_errors</code> 指令</a></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>